package objects.shared;

import objects.ObjectCodes;

import com.google.gson.Gson;

public class Message implements ObjectCodes{
	public byte type;
	public String msg;
	public String toHost;
	
	public Message(){}
	
	public Message(byte type)
	{
		this.type = type;
	}
	
	public Message(byte type, String msg)
	{
		this.type = type;
		this.msg = msg;
		this.toHost = "";
	}
	
	public Message(byte type, String msg, String toHost)
	{
		this.type = type;
		this.msg = msg;
		this.toHost = toHost;
	}
	
	public String toString()
	{
		return MSG+"|"+ new Gson().toJson(this);
	}
	
	public static Message fromJson(String json)
	{
		return new Gson().fromJson(json,Message.class);
	}

}
